home *** CD-ROM | disk | FTP | other *** search
Wrap
if(parent.updateURL) parent.updateURL(); // Processed javascript attributes var proxyJsAttr=new Array('ONCLICK', 'ONMOUSEOVER', 'ONMOUSEOUT', 'ONDBLCLICK', 'ONLOAD', 'ONRESIZE', 'ONABORT', 'ONBLUR', 'ONCHANGE', 'ONERROR', 'ONFOCUS', 'ONKEYDOWN', 'ONKEYPRESS', 'ONKEYUP','ONMOUSEDOWN', 'ONMOUSEUP', 'ONMOUSEMOVE', 'ONRESET', 'ONSELECT', 'ONSUBMIT', 'ONUNLOAD'); // Processed adress or javascript attributes var proxyLinkAttr=new Array('HREF', 'SRC', 'ACTION'); // trim function String.prototype.trim = function(){return this.replace(/^\s+|\s+$/,'');}; function proxyDgi(id){return document.getElementById(id);} // Base 64 encoding var proxyDtable = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','.','_'); function proxyB64IC(d) {r = -1; for (var proxyi = 0; proxyi < proxyDtable.length; proxyi++) {if (d == proxyDtable[proxyi]) {r = proxyi;break;}} return r;} function proxyB64F(n) {while (n > 256) { n -= 256; } return n;} function proxyB64Enc(n) { var o1 = o2 = o3 =o4 = 0; var text = ""; proxyj = 0; for (var proxyi = 0; proxyi < n.length; proxyi += 3) { t = Math.min(3, n.length - proxyi); if (t == 1) {x = n.charCodeAt(proxyi); text += proxyDtable[(x >> 2)]; text += proxyDtable[((x & 0X00000003) << 4)]; text += '-'; text += '-';} else if (t == 2) {x = n.charCodeAt(proxyi);y = n.charCodeAt(proxyi+1);text += proxyDtable[(x >> 2)];text += proxyDtable[((x & 0X00000003) << 4) | (y >> 4)];text += proxyDtable[((y & 0X0000000f) << 2)];text += '-';} else {x = n.charCodeAt(proxyi);y = n.charCodeAt(proxyi+1);z = n.charCodeAt(proxyi+2);text += proxyDtable[x >> 2];text += proxyDtable[((x & 0x00000003) << 4) | (y >> 4)];text += proxyDtable[((y & 0X0000000f) << 2) | (z >> 6)];text += proxyDtable[z & 0X0000003f];} } return text; } // Decode a proxy-encoded URL function proxyDecodeURL(encoded) { // If URL is not encoded, return if(encoded.indexOf('/proxyBrowser')==-1) return encoded; var n=encoded.substr(14+encoded.indexOf('/proxyBrowser')); n=n.substr(0,n.indexOf('/eourl/')).replace(/\//,''); var p; var o1 = o2 = o3 = 0; var text = ""; proxyj = 0; if ((n.length % 4) != 0) return null; for (var proxyi = 0; proxyi < n.length; proxyi += 4) { x1 = proxyB64IC(n.charAt(proxyi)); x2 = proxyB64IC(n.charAt(proxyi+1)); x3 = proxyB64IC(n.charAt(proxyi+2)); x4 = proxyB64IC(n.charAt(proxyi+3)); ol = 4; if (x4 == -1) { ol--; x4 = 0;} if (x3 == -1) { ol--; x3 = 0;} if (ol == 4) { o1 = ((x1 << 2) | (x2 >> 4)); ((o1 > 256) ? p=proxyB64F(o1) : p=o1) ; text += String.fromCharCode(p); o2 = ((x2 << 4) | (x3 >> 2)); ((o2 > 256) ? p=proxyB64F(o2) : p=o2) ; text += String.fromCharCode(p); o3 = ((x3 << 6) | x4); ((o3 > 256) ? p=proxyB64F(o3) : p=o3) ; text += String.fromCharCode(p); } else if (ol == 3) { o1 = ((x1 << 2) | (x2 >> 4)); ((o1 > 256) ? p=proxyB64F(o1) : p=o1) ; text += String.fromCharCode(p); o2 = ((x2 << 4) | (x3 >> 2)); ((o2 > 256) ? p=proxyB64F(o2) : p=o2); text += String.fromCharCode(p); } else if (ol == 2) { o1 = ((x1 << 2) | (x2 >> 4)); ((o1 > 256) ? p=proxyB64F(o1) : p=o1) ; text += String.fromCharCode(p); } } return text; } /** * Encode an URL into proxy format * url: real URL to encode * forceAbsolute: true to indicate that URL must include protocol+host (used by index.php wrapper) */ function proxyEncodeURL(url,forceAbsolute){ // If URL is already encoded, do nothing if(!url || url.substr(0,baseURLProxy.length)==baseURLProxy) return url; // "javascript url" if(url.substr(0,11).toLowerCase()=='javascript:') return 'javascript:'+proxyProcessJS(url.substr(11)); if(url.substr(0,2)=='//') url=siteHref.protocol+':'+url; if(url.substr(0,7).toLowerCase()!='http://' && url.substr(0,8).toLowerCase()!='https://'){ if(forceAbsolute) {url='http://'+url;} // If a <base> tag is present else if(proxyBaseHref && url.substr(0,1)!='/') { url=proxyBaseHref+url; } else { var loc=siteHref.href; var siteHost=((loc.indexOf('/',9)>0)?loc.substr(0,loc.indexOf('/',9)):loc); var tmp=((loc.indexOf('?',9)>0)?loc.substr(0,loc.indexOf('?',9)):loc); var siteHostPath=((tmp.lastIndexOf('/')>8)?tmp.substr(0,tmp.lastIndexOf('/')):tmp); siteHostDoc=tmp.substr(0,siteHostPath.length+1); if(url.substr(0,1)=='/') url=siteHost+url; else url=siteHostPath+'/'+url; } } var siteHostDoc=((url.lastIndexOf('/')>8)?url.substr(url.lastIndexOf('/')+1):''); if(siteHostDoc.indexOf('?')>=0) siteHostDoc=siteHostDoc.substr(0,siteHostDoc.indexOf('?')); var b64=''; url=proxyB64Enc(url); while(url.length>254) { b64+=url.substr(0,254)+'/'; url=url.substr(254); } return baseURLProxy+b64+url+'//eourl/a'+siteHostDoc; } function sExp(script){ var stack=''; var lastStack=''; var inquote=false; var sp=0; var prevc=''; while(sp<script.length){ c=script.charAt(sp); if(!inquote){ if(!stack && (c==','||c==';'||c=="\n"||c=="\r"||c==')'||c=='}'||c==']')) { break; } else{ if((c==')' && lastStack=='(') || (c=='}' && lastStack=='{') || (c==']' && lastStack=='[')){ stack=stack.substr(0,stack.length-1); lastStack=stack.substr(stack.length-1); } else if(c=='(' || c=='{' || c=='[') {lastStack=c;stack+=c;} else if(c=="'") inquote=1; else if(c=='"') inquote=2; else if(c=='/' && prevc=='/') inquote=3; else if(c=='*' && prevc=='/') inquote=4; } } else{ if(((inquote==1 && c=="'") || (inquote==2 && c=='"')) && prevc!='\\') inquote=0; else if(inquote==3 && ((c=="\n" || c=="\r") || (c=="/" && prevc=='/'))) inquote=0; else if(inquote==4 && c=="/" && prevc=='*') inquote=0; } prevc=c; sp++; } return (script.substr(0,sp)); } function sExpR(script,pos){ var stack=''; var lastStack=''; var inquote=false; var sp=pos; var prevc=''; var del=";,{}\n\r+-=*!:?|&/><](["; while(sp>0){ c=script.charAt(sp); prevc=script.charAt(sp-1); //document.write(c+' stack:'+stack+" inquote:"+inquote+'<br>') if(!inquote){ if(!stack && del.indexOf(c)!=-1) break; else{ if((c=='(' && lastStack==')') || (c=='{' && lastStack=='}') || (c=='[' && lastStack==']')){ stack=stack.substr(0,stack.length-1); lastStack=stack.substr(stack.length-1); } else if(c==')' || c=='}' || c==']') {lastStack=c;stack+=c;} else if(c=="'" && prevc!='\\') inquote=1; else if(c=='"' && prevc!='\\') inquote=2; } } else{ if(((inquote==1 && c=="'") || (inquote==2 && c=='"')) && prevc!='\\') inquote=0; } sp--; } return (script.substring(sp+1,pos)); } // Process javascript section function proxyProcessJS(txt){ if(!txt) return txt; txt+=""; // cast into String txt=txt.replace(/eval\s*\(/g,' proxyEval(') /* '*/ txt=txt.replace(/document\s*.\s*writeln\(/g,'proxyDocumentWriteln('); txt=txt.replace(/document\s*.\s*write\(/g,'proxyDocumentWrite('); txt=txt.replace(/window\s*.\s*open\s*\(/g,'proxyWindowOpen('); // Transform += var processed=''; while((pos=txt.search(/\.\s*((src)|(href)|(action))\s*\+=/))!=-1){ pos2=txt.indexOf('+',pos+4);pos3=txt.indexOf('=',pos+4) s=sExpR(txt,pos); expr=s+txt.substring(pos,pos2); processed=txt.substr(0,pos-s.length)+expr+"="+expr+'+'; txt=txt.substr(pos3+1); } txt=processed+txt; // process src/href/action not followed by "=": put in proxyDecodeURL() var processed=''; while((pos=txt.search(/\.\s*(((src)|(href)|(action))\s*[^=\s])/))!=-1) /* */{ pos++; s=sExpR(txt,pos); processed+=txt.substr(0,pos-s.length); while(txt.charAt(pos)==' ' || txt.charAt(pos)=="\t") pos++; if(txt.charAt(pos)=='s') {pos+=3;s+='src'} else if(txt.charAt(pos)=='h') {pos+=4;s+='href'} else {pos+=6;s+='action'} processed+='proxyDecodeURL('+s+')'; txt=txt.substr(pos); } txt=processed+txt; // process src/href/action = processed=''; while((pos=txt.search(/(\.\s*(src)|(href)|(action)\s*)=/))!=-1) /* */{ pos=txt.indexOf('=',pos); processed+=txt.substr(0,pos+1); txt=txt.substr(pos+1); s=sExp(txt); processed+='proxyEncodeURL('+s+')'; txt=txt.substr(s.length); } txt=processed+txt; // process .innerHTML processed=''; while((pos=txt.search(/\.\s*innerHTML\s*=/))!=-1) /* */ { pos=txt.indexOf('=',pos); processed+=txt.substr(0,pos+1); txt=txt.substr(pos+1); s=sExp(txt); processed+='proxyJSProcessHTML('+s+')'; txt=txt.substr(s.length); } txt=processed+txt; return txt; } // CSS processing function proxyProcessCSS(txt){ processed=''; while((pos=txt.search(/url\s*\(/i))!=-1) /* */ { pos=txt.indexOf('(',pos); processed+=txt.substr(0,pos+1); txt=txt.substr(pos+1); s=sExp(txt); processed+=proxyEncodeURL(s)+')'; txt=txt.substr(s.length); } txt=processed+txt; return txt; } function proxyProcessNode(node){ var attr; // Process onclick, onmouse... for(var proxyi=0;proxyi<proxyJsAttr.length;proxyi++) { if((attr=node.getAttribute(proxyJsAttr[proxyi]))!==null) { attr=attr.toString(); node.removeAttribute(proxyJsAttr[proxyi]); // IE Workaround node.setAttribute(proxyJsAttr[proxyi].toUpperCase(),proxyProcessJS(attr)); } } // Process href, src, action for(proxyi=0;proxyi<proxyLinkAttr.length;proxyi++) { if((attr=node.getAttribute(proxyLinkAttr[proxyi]))!==null){ node.removeAttribute(proxyLinkAttr[proxyi]); // IE Workaround if(attr.toLowerCase().substr(0,11)=='javascript:') node.setAttribute(proxyLinkAttr[proxyi],'javascript:'+proxyProcessJS(attr.substr(11))); else { node.setAttribute(proxyLinkAttr[proxyi].toUpperCase(),proxyEncodeURL(attr)); } } } // Process style if((attr=node.getAttribute('STYLE'))!==null) { attr=attr.toString(); node.removeAttribute('STYLE'); // IE Workaround node.setAttribute('STYLE',proxyProcessCSS(attr)); } // Process <script> nodes if(node.nodeName.toLowerCase()=='script'){ //alert('script:'+node.innerHTML+'>'+proxyProcessJS(node.innerHTML)) node.nodeValue=proxyProcessJS(node.innerHTML) } //for(proxyi=0;proxyi<node.childNodes.length;proxyi++) alert(node.childNodes[proxyi].nodeType+" "+node.childNodes[proxyi].nodeName); for(proxyi=0;proxyi<node.childNodes.length;proxyi++) if(node.childNodes[proxyi].nodeType==1) proxyProcessNode(node.childNodes[proxyi]); } // Process HTML code function proxyJSProcessHTML(txt){ txt+=""; if(!proxyDgi('proxyDWDOM')) document.write('<div id="proxyDWDOM" style="display:none"></div>') if(!proxyDgi('proxyDWDOM')) { var proxyDWDOMNode=document.createElement("div"); proxyDWDOMNode.setAttribute("id","proxyDWDOM"); proxyDWDOMNode.setAttribute("style","display:none"); try{document.lastChild.appendChild(proxyDWDOMNode);} catch(err){alert('Proxy: cannot create proxyDWDOM node')} } proxyDgi('proxyDWDOM').innerHTML=txt; proxyProcessNode(proxyDgi('proxyDWDOM')); txt=proxyDgi('proxyDWDOM').innerHTML; //alert('processed HTML:'+txt) proxyDgi('proxyDWDOM').innerHTML=''; //if(txt.search(/OBJECT/)!=-1) alert('pHTML:'+txt+"\n\n"+srcTxt) //alert(srcTxt+"\n\n\n"+txt) return txt; } // document.write function proxyDocumentWrite(txt){document.write(proxyJSProcessHTML(txt))} function proxyDocumentWriteln(txt){document.writeln(proxyJSProcessHTML(txt))} // Eval function proxyEval(script){ //eval(proxyProcessJS(script)); try{eval(proxyProcessJS(script))} catch(err){/*alert('proxyEval error'); alert(script)*/} } // setTimeout function proxySetTimeout(script,timeout){setTimeout(proxyProcessJS(script),timeout)} // setInterval function proxySetInterval(script,timeout){setInterval(proxyProcessJS(script),timeout)} // window.open function proxyWindowOpen(url,a,b){window.open(proxyEncodeURL(url),a,b)} // Watch document.location modifications function watchProxyDocumentLocation(){ if(!proxyDgi('proxyDocumentLocationNode')){ //document.write('<div id="proxyDocumentLocation" style="display:none"></div>') if(!document.body) return; var proxyDocumentLocationNode=document.createElement("input"); proxyDocumentLocationNode.setAttribute("id","proxyDocumentLocationNode"); proxyDocumentLocationNode.setAttribute("style","display:none"); document.body.appendChild(proxyDocumentLocationNode); } var proxyNURL=proxyDgi('proxyDocumentLocationNode').value+""; if(!proxyNURL) return; if(proxyNURL.substr(0,baseURLProxy.length)==baseURLProxy) document.location=proxyNURL; else document.location=proxyEncodeURL(proxyNURL); proxyDgi('proxyDocumentLocationNode').value=''; } /** * document.location replacement */ function proxyDocumentLocation(url){ this.href=String(url); this.port=''; this.protocol=url.substr(0,url.indexOf('://')); this.hash=''; this.pathname=''; this.search=''; url=url.substr(url.indexOf('://')+3); if(url.indexOf(':')!=-1 && (url.indexOf('/')==-1 || url.indexOf(':')<url.indexOf('/'))){ this.host=url.substr(0,url.indexOf(':')); if((url.indexOf('/')==-1)){this.port=url.substr(url.indexOf(':')+1);url='';} else{this.port=url.substring(url.indexOf(':')+1,url.indexOf('/'));url=url.substr(url.indexOf('/'));} } else{ if(url.indexOf('/')==-1){this.host=url;url=''} else{this.host=url.substr(0,url.indexOf('/'));url=url.substr(url.indexOf('/'));} } this.hostname=this.domain=this.host; if(url.indexOf('#')!=-1){ this.hash=url.substr(url.indexOf('#')); url=url.substr(0,url.indexOf('#')); } if(url.indexOf('?')!=-1){ this.search=url.substr(url.indexOf('?')); url=url.substr(0,url.indexOf('?')); } this.pathname=url; } // Document.location functions proxyDocumentLocation.prototype.toString=function(){return this.href} proxyDocumentLocation.prototype.reload=function(){document.location.reload()} proxyDocumentLocation.prototype.replace=function(url){document.location.replace(proxyEncodeURL(url))} proxyDocumentLocation.prototype.anchor=function(a){return this.href.anchor(a)} // String functions proxyDocumentLocation.prototype.big=function(){return this.href.big()} proxyDocumentLocation.prototype.blink=function(){return this.href.blink()} proxyDocumentLocation.prototype.bold=function(){return this.href.bold()} proxyDocumentLocation.prototype.charAt=function(a){return this.href.charAt(a)} proxyDocumentLocation.prototype.charCodeAt=function(a){return this.href.charCodeAt(a)} proxyDocumentLocation.prototype.concat=function(a){return this.href.concat(a)} proxyDocumentLocation.prototype.fixed=function(){return this.href.fixed()} proxyDocumentLocation.prototype.fontcolor=function(a){return this.href.fontcolor(a)} proxyDocumentLocation.prototype.fontsize=function(a){return this.href.fontsize(a)} proxyDocumentLocation.prototype.indexOf=function(a,b){return this.href.indexOf(a,b)} proxyDocumentLocation.prototype.italics=function(){return this.href.italics()} proxyDocumentLocation.prototype.lastIndexOf=function(a,b){return this.href.lastIndexOf(a,b)} proxyDocumentLocation.prototype.link=function(a){return this.href.link(a)} proxyDocumentLocation.prototype.match=function(a){return this.href.match(a)} proxyDocumentLocation.prototype.slice=function(a,b){return this.href.slice(a,b)} proxyDocumentLocation.prototype.small=function(){return this.href.small()} proxyDocumentLocation.prototype.split=function(a,b){return this.href.split(a,b)} proxyDocumentLocation.prototype.strike=function(){return this.href.strike()} proxyDocumentLocation.prototype.sub=function(){return this.href.sub()} proxyDocumentLocation.prototype.substr=function(a,b){return this.href.substr(a,b)} proxyDocumentLocation.prototype.substring=function(a,b){return this.href.substring(a,b)} proxyDocumentLocation.prototype.sup=function(){return this.href.sup()} proxyDocumentLocation.prototype.toLowerCase=function(){return this.href.toLowerCase()} proxyDocumentLocation.prototype.toUpperCase=function(){return this.href.toUpperCase()} var watchProxyDocumentLocationInt=window.setInterval("watchProxyDocumentLocation()",100); /** * document.location replacement */ function proxyDocument(){ this.location = siteHref; } proxyDocument.prototype.write=function(a){proxyDocumentWrite(a)} proxyDocument.prototype.writeln=function(a){proxyDocumentWriteln(a)} /** * Cookies management */ // Clear remaining cookies function proxyClearCookie(){ var cookies=document.cookie.split('; '); //for(var i=0;i<cookies.length;i++) document.cookie=cookies[i]+'; expires='+proxyDateExpire; for(var i=0;i<cookies.length;i++) if(cookies[i].substr(0,12)=='proxyCookie') document.cookie=cookies[i].substr(0,cookies[i].indexOf(':'))+'=0; expires='+proxyDateExpire; } proxyClearCookie(); // Get cookies list function proxyGetCookie(value){return proxyCookies} // Set/unset/modify a cookie function proxySetCookie(value){ var expires=0; // Determine if an expire date is set if(value.indexOf(';')!=-1){ var tail=value.substr(value.indexOf(';')+1).trim(); if(tail.substr(0,8)=='expires=') expires=tail.substr(8).trim(); value=value.substr(0,value.indexOf(';')); } if(value.indexOf('=')==-1) return; var name=value.substr(0,value.indexOf('=')); value=value.substr(value.indexOf('=')+1).trim(); if(value.indexOf(';')!=-1) value=value.substr(0,value.indexOf(';')); // Check if this cookie is present var cookies=proxyCookies.split('; '); proxyCookies=''; // Remove this new or updated cookie from js cookies list for(var i=0;i<cookies.length;i++){ if(cookies[i].substr(0,name.length+1)!=name+'=') proxyCookies+='; '+cookies[i]; } // Then add it to js cookies list if(!expires || new Date(expires)>new Date) proxyCookies+='; '+name+'='+value; proxyCookies=proxyCookies.substr(1); // Add it to real cookies to send it to browser document.cookie='proxyCookie'+name+'=expires/'+((expires)?(Date.parse(expires)/1000):'session')+'/'+value; }